#pragma once
#include"rbtree.h"
#include<iostream>
using namespace std;

template<class K,class V>
class mymap
{
	struct mapkeyofT
	{
		const K& operator()(const pair<K,V>& data)
		{
			return data.first;
		}
	};
	public:

		typedef typename RBTree<K, pair<const K, V>, mapkeyofT>::Iterator iterator;
		iterator begin()
		{
			return _t.begin();
		}
		iterator end()
		{
			return _t.end();
		}
		pair<iterator,bool> insert(const pair<K,V> kv)
		{
			return _t.Insert(kv);
		}
		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _t.Insert(make_pair(key, V()));
			return ret.first->second;
		}
		iterator find(const K& key)
		{
			return _t.find(key);
		}
	private:
		RBTree<K, pair<const K,V>, mapkeyofT> _t;
};
